package com.hjb.service.mybatis;

import com.github.pagehelper.PageHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @author <a href="mailto:panxinwen@yingu.com">Pan Xinwen</a>
 * @version 1.0 2016年12月14日 上午9:59:43
 */
@Configuration
public class PageHelperConfig {
  private Logger logger = LoggerFactory.getLogger(PageHelperConfig.class);
  	/**
  	 * 
  	* @Title: pageHelper
  	* @Description: TODO(注册分页插件)
  	* @return    
  	* @return PageHelper
  	 */
  @Bean
  public PageHelper pageHelper() {
    logger.info("注册MyBatis分页插件PageHelper");
    PageHelper pageHelper = new PageHelper();
    Properties properties = new Properties();
    properties.setProperty("offsetAsPageNum", "true");
    properties.setProperty("rowBoundsWithCount", "true");
    properties.setProperty("reasonable", "true");
    pageHelper.setProperties(properties);
    return pageHelper;
  }
}
